/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hotelroom;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author ndry93
 */
public class Level extends JPanel{
private JButton btnLvl1,btnLvl2,btnLvl3,btnLvl4,btnLvl5,btnLvl6;
    public Level(){
        setBackground(Color.BLACK);
        setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        btnLvl1 = new JButton("Level 1");
        btnLvl2 = new JButton("Level 2");
        btnLvl3 = new JButton("Level 3");
        btnLvl4 = new JButton("Level 4");
        btnLvl5 = new JButton("Level 5");
        btnLvl6 = new JButton("Level 6");
        btnLvl1.setRequestFocusEnabled(true);
        btnLvl2.setRequestFocusEnabled(true);
        btnLvl3.setRequestFocusEnabled(true);
        btnLvl4.setRequestFocusEnabled(true);
        btnLvl5.setRequestFocusEnabled(true);
        btnLvl6.setRequestFocusEnabled(true);
        btnLvl1.setVisible(true);
        btnLvl2.setVisible(true);
        btnLvl3.setVisible(true);
        btnLvl4.setVisible(true);
        btnLvl5.setVisible(true);
        btnLvl6.setVisible(true);
        btnLvl1.addActionListener(new HandlerClass());
        btnLvl2.addActionListener(new HandlerClass());
        btnLvl3.addActionListener(new HandlerClass());
        btnLvl4.addActionListener(new HandlerClass());
        btnLvl5.addActionListener(new HandlerClass());
        btnLvl6.addActionListener(new HandlerClass());
        c.insets = new Insets(2,2,2,2);
        this.add(btnLvl1,c);
        this.add(btnLvl2,c);
        this.add(btnLvl3,c);
        this.add(btnLvl4,c);
        this.add(btnLvl5,c);
        this.add(btnLvl6,c);
        Toolkit toolkit =  Toolkit.getDefaultToolkit ();
        Dimension dim = toolkit.getScreenSize();
        this.setPreferredSize(new Dimension(dim.width,50));
        this.setVisible(true);
    }
    
    class HandlerClass implements ActionListener{
        @Override
            public void actionPerformed (ActionEvent e){
            ValueHandler vh = new ValueHandler();
                if(e.getSource() == btnLvl1){
                    if(vh.getLevel()!=1)
                    {
                        vh.setLevel(1);
                        vh.setLvlIsChanged(true);
                    }
                }else if(e.getSource() == btnLvl2){
                    if(vh.getLevel()!=2)
                    {
                        vh.setLevel(2);
                        vh.setLvlIsChanged(true);
                    }
                }else if(e.getSource() == btnLvl3){
                    if(vh.getLevel()!=3)
                    {
                        vh.setLevel(3);
                        vh.setLvlIsChanged(true);
                    }
                }else if(e.getSource() == btnLvl4){
                    if(vh.getLevel()!=4)
                    {
                        vh.setLevel(4);
                        vh.setLvlIsChanged(true);
                    }
                }else if(e.getSource() == btnLvl5){
                    if(vh.getLevel()!=5)
                    {
                        vh.setLevel(5);
                        vh.setLvlIsChanged(true);
                    }
                }else if(e.getSource() == btnLvl6){
                    if(vh.getLevel()!=6)
                    {
                        vh.setLevel(6);
                        vh.setLvlIsChanged(true);
                    }
                }
                
        }
    }
}
